

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>块设备入门 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="iSCSI Initiators 的配置" href="../../rbd/iscsi-initiators/" />
    <link rel="prev" title="手动安装 ceph-iscsi" href="../../rbd/iscsi-target-cli-manual-install/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../rbd/">Ceph 块设备</a></li>
          <li class="breadcrumb-item"><a href="../../rbd/rbd-integrations/">Ceph 块设备与第三方对接</a></li>
          <li class="breadcrumb-item"><a href="../../rbd/iscsi-overview/">Ceph iSCSI Gateway</a></li>
          <li class="breadcrumb-item"><a href="../../rbd/iscsi-targets/">iSCSI Targets</a></li>
          <li class="breadcrumb-item"><a href="../../rbd/iscsi-target-cli/">用命令行配置 iSCSI Target</a></li>
      <li class="breadcrumb-item active">块设备入门</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/start/quick-rbd.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../rbd/">Ceph 块设备</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../rbd/rados-rbd-cmds/">基本命令</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../rbd/rbd-operations/">运维</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../../rbd/rbd-integrations/">对接</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../../rbd/rbd-ko/">内核模块</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../rbd/qemu-rbd/">QEMU</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../rbd/libvirt/">libvirt</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../rbd/rbd-kubernetes/">Kubernetes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../rbd/rbd-nomad/">Nomad</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../rbd/rbd-openstack/">OpenStack</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../rbd/rbd-cloudstack/">CloudStack</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="../../rbd/iscsi-overview/">LIO iSCSI Gateway</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../../rbd/iscsi-requirements/">Requirements</a></li>
<li class="toctree-l4 current"><a class="reference internal" href="../../rbd/iscsi-targets/">Configuring the iSCSI Target</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../rbd/iscsi-initiators/">Configuring the iSCSI Initiators</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../rbd/iscsi-monitoring/">Monitoring the iSCSI Gateways</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../rbd/rbd-windows/">Windows</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../rbd/nvmeof-overview/">NVMe-oF 网关</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../rbd/man/">手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../rbd/api/">APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="id1">
<h1>块设备入门<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h1>
<p>开始用 <a class="reference internal" href="../../glossary/#term-2"><span class="xref std std-term">Ceph 块设备</span></a>之前，先确认 <a class="reference internal" href="../../glossary/#term-28"><span class="xref std std-term">Ceph 存储集群</span></a>处于 <code class="docutils literal notranslate"><span class="pre">active</span> <span class="pre">+</span> <span class="pre">clean</span></code> 状态。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Ceph 块设备也叫 <a class="reference internal" href="../../glossary/#term-RBD"><span class="xref std std-term">RBD</span></a> 或 <a class="reference internal" href="../../glossary/#term-RADOS"><span class="xref std std-term">RADOS</span></a> 块设备。</p>
</div>
<p class="ditaa">
<img src="../../_images/ditaa-05e32dee11ccebcdeec92ea7a3c78c20247270e1.png"/>
</p>
<p>你可以在虚拟机上运行 <code class="docutils literal notranslate"><span class="pre">ceph-client</span></code> 节点，但是不能在与 Ceph 存储集群
（除非它们也用 VM ）相同的物理节点上执行下列步骤。详情见 <a class="reference external" href="http://wiki.ceph.com/How_Can_I_Give_Ceph_a_Try">FAQ</a> 。</p>
<section id="id2">
<h2>创建一个块设备存储池<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<ol class="arabic">
<li><p>在管理节点上，用 <code class="docutils literal notranslate"><span class="pre">ceph</span></code> 工具来<a class="reference external" href="../../rados/operations/pools/#create-a-pool">创建一个存储池</a>（我们建议以 rbd 为名）；</p></li>
<li><p>在管理节点上，用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 工具来初始化新建的存储池，这样才能用作 RBD:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">pool</span> <span class="n">init</span> <span class="o">&lt;</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="o">&gt;</span>
</pre></div>
</div>
</li>
</ol>
</section>
<section id="id3">
<h2>配置块设备<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<ol class="arabic">
<li><p>在 <code class="docutils literal notranslate"><span class="pre">ceph-client</span></code> 节点上创建一个块设备映像。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rbd</span> <span class="n">create</span> <span class="n">foo</span> <span class="o">--</span><span class="n">size</span> <span class="mi">4096</span> <span class="o">--</span><span class="n">image</span><span class="o">-</span><span class="n">feature</span> <span class="n">layering</span> <span class="p">[</span><span class="o">-</span><span class="n">m</span> <span class="p">{</span><span class="n">mon</span><span class="o">-</span><span class="n">IP</span><span class="p">}]</span> <span class="p">[</span><span class="o">-</span><span class="n">k</span> <span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">admin</span><span class="o">.</span><span class="n">keyring</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">p</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span>
</pre></div>
</div>
</li>
<li><p>在 <code class="docutils literal notranslate"><span class="pre">ceph-client</span></code> 节点上，把映像映射为块设备。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">rbd</span> <span class="nb">map</span> <span class="n">foo</span> <span class="o">--</span><span class="n">name</span> <span class="n">client</span><span class="o">.</span><span class="n">admin</span> <span class="p">[</span><span class="o">-</span><span class="n">m</span> <span class="p">{</span><span class="n">mon</span><span class="o">-</span><span class="n">IP</span><span class="p">}]</span> <span class="p">[</span><span class="o">-</span><span class="n">k</span> <span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">admin</span><span class="o">.</span><span class="n">keyring</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">p</span> <span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span>
</pre></div>
</div>
</li>
<li><p>在 <code class="docutils literal notranslate"><span class="pre">ceph-client</span></code> 节点上，创建文件系统后就可以使用了。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">mkfs</span><span class="o">.</span><span class="n">ext4</span> <span class="o">-</span><span class="n">m0</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">rbd</span><span class="o">/</span><span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">/</span><span class="n">foo</span>
</pre></div>
</div>
<p>此命令可能耗时较长。</p>
</li>
<li><p>在 <code class="docutils literal notranslate"><span class="pre">ceph-client</span></code> 节点上挂载此文件系统。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">mkdir</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">ceph</span><span class="o">-</span><span class="n">block</span><span class="o">-</span><span class="n">device</span>
<span class="n">sudo</span> <span class="n">mount</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">rbd</span><span class="o">/</span><span class="p">{</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">/</span><span class="n">foo</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">ceph</span><span class="o">-</span><span class="n">block</span><span class="o">-</span><span class="n">device</span>
<span class="n">cd</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">ceph</span><span class="o">-</span><span class="n">block</span><span class="o">-</span><span class="n">device</span>
</pre></div>
</div>
</li>
<li><p>如果你想让块设备在启动时自动映射并挂载（而且在关机时卸载并取消映射），请参考 <a class="reference external" href="../../man/8/rbdmap">rbdmap 手册页</a>。</p></li>
</ol>
<p>详情见<a class="reference external" href="../../rbd">块设备</a> 。</p>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../../rbd/iscsi-target-cli-manual-install/" class="btn btn-neutral float-left" title="手动安装 ceph-iscsi" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../../rbd/iscsi-initiators/" class="btn btn-neutral float-right" title="iSCSI Initiators 的配置" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>